package com.imut.oa.controller.admin;


import com.imut.oa.common.BaseResponse;
import com.imut.oa.common.PageResult;
import com.imut.oa.common.ResultUtils;
import com.imut.oa.pojo.dto.ExpensePageQueryDTO;
import com.imut.oa.pojo.dto.ExpenseUpdateStatusDTO;
import com.imut.oa.pojo.entity.Expense;
import com.imut.oa.pojo.vo.ExpenseVO;
import com.imut.oa.service.ExpenseService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/expense")
@Slf4j
@Tag(name = "报销管理")
public class ExpenseController {
    @Autowired
    private ExpenseService expenseService;

    @PostMapping("/page")
    @Operation(summary = "分页获取报销列表")
    public BaseResponse<PageResult> page(@RequestBody ExpensePageQueryDTO expensePageQueryDTO) {
        log.info("报销分页查询：{}",expensePageQueryDTO);
        PageResult pageResult = expenseService.page(expensePageQueryDTO);
        return ResultUtils.success(pageResult);
    }

    @PostMapping("/updateStatus")
    @Operation(summary = "更新报销状态")
    public BaseResponse<Integer> updateStatus(@RequestBody ExpenseUpdateStatusDTO dto) {
         expenseService.updateStatus(dto);
        return ResultUtils.success(null,"修改成功");
    }

    @PostMapping("/delete/{id}")
    @Operation(summary = "删除报销记录")
    public BaseResponse<Integer> deleteById(@PathVariable Long id) {
        int result = expenseService.deleteById(id);
        return ResultUtils.success(result);
    }
}